#include <cstdio>
#include "CircularReference.h"
#include "VirtualFunc_in_Ctor_Dtor.h"
#include "CastingSibling.h"
#include "RedefineAnInheritedNon-virtualFunc.h"
#include "DontCopyMe.h"

void test0() {
	int a = 0, b = 1, c = 2;
	printf("%d %d\n",a);
}

void test1() {
	boost::shared_ptr<A> pa(new A);
	boost::shared_ptr<B> pb(new B);
	pa->pb = pb;
	pb->pa = pa;
}

void test2() {
	Derived d;
}

void test3() {
	LeftChild *lc = new LeftChild;
	//RightChild *rc = static_cast<RightChild*>(lc); //doesn't compile
	RightChild *rc = dynamic_cast<RightChild*>(lc);

	LeftChild lc1;
	Root r = static_cast<Root>(lc1);
}

void test4() {
	DerivedDerived2 d;
	Base2* pb = &d;
	pb->name();
	Derived2* pd = &d;
	pd->name();
	DerivedDerived2* pdd = &d;
	pdd->name();
}

void test_noncopyable() {
	DontCopyMe a;
	DontCopyMe b(a);
}

void foo(){
	int i = 1;
	//1000 lines of codes without referencing i
	std::cout << i << std::endl;
}

void test_implicit_var_change() {
	const int i = 1;
	int j = 2;
	int * pj = &j;
	const int * pi = &i;
	int * pji = pj + 3;
	*(pji) = 2;
	std::cout << "i = " << i << std::endl;
}

int main(){
	/*test0();*/
	//test1();
	//test2();
	//test4();
	//test_noncopyable();
	test_implicit_var_change();
}